/**
 * 仅限于位运算页面的输入使用
 * by littlefean
 */

class ComputeEle {
    constructor(bindEle) {
        this.aEle = bindEle.querySelector(".n1");
        this.bEle = bindEle.querySelector(".n2");
        this.a = +this.aEle.value;
        this.b = +this.bEle.value;
        this.op = bindEle.querySelector(".op").innerText;
        this.outputEle = bindEle.querySelector(".output");
    }

    run() {
        this.a = +this.aEle.value;
        this.b = +this.bEle.value;
        let res = NaN;
        try {
            res = eval(`${this.a}${this.op}${this.b}`);
        } catch (e) {
            console.log(e);
        }
        // alert(res);
        this.outputEle.innerText = res.toString();
    }
}

/**
 * 取反的操作
 */
class ComputeEleRev {
    constructor(bindEle) {
        this.aEle = bindEle.querySelector(".n1");
        this.a = +this.aEle.value;
        this.op = bindEle.querySelector(".op").innerText;
        this.outputEle = bindEle.querySelector(".output");
    }

    run() {
        this.a = +this.aEle.value;
        let res = NaN;
        try {
            res = eval(`${this.op}${this.a}`);
        } catch (e) {
            console.log(e);
        }
        // alert(res);
        this.outputEle.innerText = res.toString();
    }
}
